package bma.common.langutil.bean.copy;

import bma.common.langutil.core.Function;

public class BeanCast<OUT_TYPE, IN_TYPE> implements Function<IN_TYPE, OUT_TYPE> {

	private BeanCopyTool copyTool;

	private Class<OUT_TYPE> clazz;

	public BeanCast() {
		super();
	}

	public BeanCast(BeanCopyTool copyTool, Class<OUT_TYPE> clazz) {
		super();
		this.copyTool = copyTool;
		this.clazz = clazz;
	}

	public BeanCopyTool getCopyTool() {
		return this.copyTool;
	}

	public void setCopyTool(BeanCopyTool copyTool) {
		this.copyTool = copyTool;
	}

	public Class<OUT_TYPE> getClazz() {
		return this.clazz;
	}

	public void setClazz(Class<OUT_TYPE> clazz) {
		this.clazz = clazz;
	}

	@Override
	public OUT_TYPE apply(IN_TYPE obj) {
		return this.copyTool.newInstance(null, obj, this.clazz);
	}

}
